import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { I18NService } from 'cxd/shared';

@Component({
  selector: 'app-example-links',
  templateUrl: './example-links.component.html',
  styleUrls: ['./example-links.component.scss'],
})
export class ExampleLinksComponent implements OnInit {
  @Input() prePath;
  @Input() nextPath;
  @Input() rootLink = '';

  preLabel = '';
  nextLabel = '';
  prePathLink: string;
  nextPathLink: string;
  currentLang: string;

  constructor(public i18n: I18NService) {}

  ngOnInit(): void {
    this.currentLang = this.i18n.language;

    if (this.prePath) {
      this.preLabel = this.i18n.get(this.prePath)[0];
      this.prePathLink = `/${this.rootLink}/${this.prePath}`;
    }

    if (this.nextPath) {
      this.nextLabel = this.i18n.get(this.nextPath)[0];
      this.nextPathLink = `/${this.rootLink}/${this.nextPath}`;
    }
  }
}
